package com.bit.ioc;

import com.bit.ioc.controller.UserController;
import com.bit.ioc.controller.UserController2;
import com.bit.ioc.controller.UserController3;
import com.bit.ioc.model.UserInfo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

//@ComponentScan(basePackages = "com.bit.ioc")
@SpringBootApplication
public class SpringIocDemoApplication {

	public static void main (String[] args) {
		ApplicationContext context = SpringApplication.run(SpringIocDemoApplication.class, args);
//		UserController bean = context.getBean(UserController.class);
//		System.out.println(bean);
//		bean.sayHi();
//
//		UserController userController = (UserController) context.getBean("userController");
//		System.out.println(userController);
//		userController.sayHi();

//		UserController userController = (UserController) context.getBean("userController");
//		userController.sayHi();

		//构造方法注入
//		UserController2 userController2 = context.getBean(UserController2.class);
//		userController2.sayHi();

		//Setter方法注入
//		UserController3 userController3 = context.getBean(UserController3.class);
//		userController3.sayHi();

//		UserController userController1 = context.getBean("userController", UserController.class);
//		System.out.println(userController1);
//		userController1.sayHi();

//		UserService bean = context.getBean(UserService.class);
//		bean.doService();
//		UserRepository bean = context.getBean("ur", UserRepository.class);
//		bean.doRepository();
//
//		UserComponent bean1 = context.getBean(UserComponent.class);
//		bean1.doComponent();
//
//		UserConfig bean2 = context.getBean(UserConfig.class);
//		bean2.doConfig();

//		DataSourceLinkFactory bean = context.getBean(DataSourceLinkFactory.class);
//		System.out.println(bean);
//		UserInfo bean = context.getBean("zhangsan", UserInfo.class);
//		System.out.println(bean);
//
//		UserInfo bean1 = context.getBean("user1", UserInfo.class);
//		System.out.println(bean1);
//
//		UserInfo bean2 = context.getBean("user2", UserInfo.class);
//		System.out.println(bean2);
	}

}
